﻿<UserControl x:Class="Assembly.Metro.Controls.PageTemplates.Games.Components.MetaComponents.tagValue"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:Assembly.Metro.Controls.PageTemplates.Games.Components.MetaComponents"
             xmlns:games="clr-namespace:Assembly.Metro.Controls.PageTemplates.Games"
             mc:Ignorable="d" Height="35" Width="785"
             HorizontalAlignment="Left"
             x:Name="control">
    <UserControl.Resources>
        <local:TagClassConverter x:Key="classToIndexConverter" TagsSource="{Binding DataContext.Tags, Source={x:Reference control}}" />
        <local:TagEntryListRetriever x:Key="classItemsRetriever" />
        <DataTemplate DataType="{x:Type games:TagClass}">
            <TextBlock Text="{Binding TagClassMagic}" />
        </DataTemplate>
        <DataTemplate DataType="{x:Type games:TagEntry}">
            <TextBlock Text="{Binding TagFileName}" />
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <StackPanel Orientation="Horizontal">
            <TextBlock x:Name="lblValueName" Text="{Binding Path=Name}" ToolTip="{Binding Path=Name}" Style="{DynamicResource GenericTextblock}" Width="180" VerticalAlignment="Center" Margin="0,0,0,0" TextTrimming="CharacterEllipsis"/>
            <ComboBox x:Name="cbTagClass" Width="80" VerticalAlignment="Center" Margin="20,0,0,0" SelectionChanged="cbTagClass_SelectionChanged"
                      ItemsSource="{DynamicResource classList}" SelectedIndex="{Binding Class, Mode=TwoWay, Converter={StaticResource classToIndexConverter}}">
                <ComboBox.Resources>
                    <CompositeCollection x:Key="classList">
                        <ComboBoxItem>(null)</ComboBoxItem>
                        <CollectionContainer Collection="{Binding DataContext.Tags.Classes, Source={x:Reference cbTagClass}}" />
                    </CompositeCollection>
                </ComboBox.Resources>
            </ComboBox>
            
            <ComboBox x:Name="cbTagEntry" Width="400" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="10,0,0,0"
                      ItemsSource="{Binding Class, Converter={StaticResource classItemsRetriever}, Mode=OneWay}"
                      SelectedItem="{Binding Value, Mode=TwoWay}" />

            <Button x:Name="btnJumpToTag" Content="Jump To" Margin="10,0,0,0" Width="75" Click="btnJumpToTag_Click" Visibility="{Binding ShowJumpTo}" />
        </StackPanel>
    </Grid>
</UserControl>
